/**
 * 对应管理员端预测模块
 */
package xiangmu.schoolpaper.controller.system;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xiangmu.schoolpaper.pojo.DTO.KeywordsQuery;
import xiangmu.schoolpaper.result.Result;
import xiangmu.schoolpaper.service.impl.system.PredictionKeywordsServiceImpl;
import xiangmu.schoolpaper.service.system.PredictionKeywordsService;
//import xiangmu.schoolpaper.service.Impl.UploadFileToKimiServiceImpl;

import java.util.List;
import java.util.Map;



@Slf4j
@RestController
@RequestMapping("/system/prediction")
@Tag(name="预测接口")
public class PredictionKeywordsController {

    @Autowired
    private PredictionKeywordsService predictionKeywordsService;

    @GetMapping("/getTop15Keywords")
    @Operation(summary = "根据年级专业获取top15的关键词")
    public Result<List<Map<String, Object>>> getSysPredictionKeywords(
            @RequestParam(required = false) String major,
            @RequestParam(required = false) String grade
    ){
        log.info("根据年级专业获取top15的关键词");
        if( grade == null ) grade = "2025";
        List<Map<String, Object>> list = predictionKeywordsService.getKeywordsTable(major,grade);
        return Result.success(list);
    }

    @GetMapping("/getAiPredictByKeywords")
    @Operation(summary = "根据关键词和用户输入AI预测关键词热点")
    public  Result<String> AiPredictByKeywords(@RequestParam(required = false) String query){
        log.info("根据关键词和用户输入AI预测关键词热点");
        String guo = predictionKeywordsService.AiPredictByKeywords(query);
        return Result.success(guo);
    }

    @GetMapping("/getAllMajors")
    @Operation(summary = "获取所有专业的专业名称")
    public Result<List<String>> getAllMajors(){
        log.info("获取所有专业的专业名称");
        List<String> list = predictionKeywordsService.getAllMajors();
        return Result.success(list);
    }
    @GetMapping("/getAllCompletionYears")
    @Operation(summary = "从论文完成时间抽取所有的毕业年级")
    public Result<List<Integer>> getAllCompletionYears(){
        log.info("从论文完成时间抽取所有的毕业年级");
        List<Integer> list = predictionKeywordsService.getAllCompletionYears();
        return Result.success(list);
    }
}
